﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WindowsGame4
{
    class World
    {
        private int rows;
        private int columns;
        private Cell[,] cells;
        private int size;

        public World(int rows, int columns, int size)
        {
            this.rows = rows;
            this.columns = columns;
            this.size = size;
            cells = new Cell[rows, columns];
            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < columns; j++)
                    cells[i, j] = new Cell(i, j, size);
            }
        }

        public Cell get(int row, int column)
        {
            return cells[row, column];
        }

        public void set(Cell cell, int row, int column)
        {
            cells[row, column] = cell;
        }

        public int Rows
        {
            get { return rows; }
            set { rows = value; }
        }

        public int Columns
        {
            get { return columns; }
            set { columns = value; }
        }

        public int getNumRow(int x)
        {
            return x / size;
        }

        public int getNumColumn(int y)
        {
            return y / size;
        }

        public int Size
        {
            get { return size; }
            set { size = value; }
        }

        override public String ToString()
        {
            String result = "";
            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < columns; j++)
                {
                    Cell cell = cells[i, j];
                    if (cell.Obj == null)
                        result += "0 ";
                    else
                    {
                        if (cell.Obj.Type == Object.TypeObject.player)
                            result += "2 ";
                        else
                        {
                            if (cell.Obj.Type == Object.TypeObject.enemy)
                                result += "3 ";
                            else
                                result += "1 ";
                        }
                            
                    }
                }
                result += "\n";
            }
            return result;
        }

    }
}
